package base;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;


public class Base {

	String fichierConfig = "base";
	String url = null;
	String user = null;
	String password = null;
	
	Connection connection = null;
	
	public Base() {
		ResourceBundle rs = 
			ResourceBundle.getBundle(fichierConfig);
		url = rs.getString("url");
		user = rs.getString("user");
		password = rs.getString("password");
	}
	
	public Connection getConnection() {
		return connection;
	}

	public void ouvrir() {
		try {
			connection = DriverManager.getConnection(url, user, password);
		} catch (SQLException e) {
			System.out.println("Base.ouvrir: erreur url = "+url+" : "+e.toString());
		}
	}
	
	public void fermer() {
		try {if (connection != null) connection.close();} catch (Exception e) {}
	}


	
}
